#include <Python.h>
#include "getsize.h"
#include "diskiopyobj.h"
PyGILState_STATE gstate = PyGILState_Ensure();
auto pickleModule = PyImport_ImportModule("dumpobj");
auto dumpsFunc = PyObject_GetAttrString(pickleModule, "saveobj");
auto loadsFunc = PyObject_GetAttrString(pickleModule, "loadobj");
bool releasegil(PyGILState_STATE a);
bool gstatetmp = releasegil(gstate);
bool releasegil(PyGILState_STATE a) {
    PyGILState_Release(a);
    return true;
}
void savePyObject(char* filePath, PyObject * pyObject) {
    PyObject* pArgs = PyTuple_Pack(2, Py_BuildValue("s", filePath), pyObject);
    PyObject_CallObject(dumpsFunc, pArgs);
    Py_XDECREF(pArgs);
    //PyErr_Print();
}

PyObject* loadPyObject(char* filePath) {
    PyObject* pArgs = PyTuple_Pack(1, Py_BuildValue("s", filePath));
    PyObject* pResult = PyObject_CallObject(loadsFunc, pArgs);
    Py_XDECREF(pArgs);
    //PyErr_Print();
    return pResult;
}